package util

import (
	"sieve_admin_server/app/server"
	"strconv"
)

type API interface {
	GetApis() []*server.BatchModTree
	Cron()
}

type EmptyAPI struct {
}

func (EmptyAPI) GetApis() []*server.BatchModTree {
	return nil
}

func (EmptyAPI) Cron() {
	return
}

func (EmptyAPI) GetModTree() {
	return
}

func ToInt(v string) int {
	n, err := strconv.Atoi(v)
	if err != nil {
		n = 0
	}
	return n
}

func ToInt64(v string) int64 {
	n, err := strconv.ParseInt(v, 10, 64)
	if err != nil {
		n = 0
	}
	return n
}

func ToIntStr(v int) string {
	return strconv.Itoa(v)
}

func ToInt64Str(v int64) string {
	return strconv.FormatInt(v, 10)
}
